package cn.jhc.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.bean.Role;
import cn.jhc.bean.User;
import cn.jhc.dao.DaoType;
import cn.jhc.dao.RoleDAO;
import cn.jhc.dao.UserDao;
import cn.jhc.factory.DAOFactory;

/**
 * Servlet implementation class ShowpublisherServlet
 */
@WebServlet("/showuser.htm")
public class ShowuserinfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		List<User> userlist = new ArrayList();
		UserDao pdao = (UserDao)DAOFactory.getDao(DaoType.USER);
		List<Role> rolelist = new ArrayList();
		RoleDAO rdao = (RoleDAO)DAOFactory.getDao(DaoType.ROLE);
		rolelist = rdao.getGroups();		
		userlist = pdao.getAll();
		request.setAttribute("rolelist", rolelist);
		request.setAttribute("userlist", userlist);
		request.getRequestDispatcher("/admin/admin.jsp?body=/tiles/showUserinfo.jsp").forward(request, response);
	}

}
